package cn.dduan.fool.design.pattern.great.single;

/**
 * 静态内部类单例
 * <p>
 * 是否线程安全：是
 * 是否懒加载：是
 * 优点：静态内部类赋值实际是调用 方法，而虚拟机保证 方法使用锁，保证线程安全
 *
 * @author dduan
 * @version 1.0
 * @date 2023/3/17
 */
public class StaticInnerClass {
    private StaticInnerClass() {
    }

    private static class SingletonHolder {
        private static final SingletonHolder INSTANCE = new SingletonHolder();
    }

    public static final SingletonHolder getInstance() {
        return SingletonHolder.INSTANCE;
    }
}
